//
//  WRYEssenceController.m
//  BaiSiBuJie
//
//  Created by wry on 16/4/24.
//  Copyright © 2016年 WRY. All rights reserved.
//

#import "WRYEssenceController.h"

#import "UIBarButtonItem+WRYHighlightButton.h"
#import "WRYSubTagController.h"

#import "WRYAllController.h"
#import "WRYVideoController.h"
#import "WRYVoiceController.h"
#import "WRYPictureController.h"
#import "WRYTextViewController.h"


@interface WRYEssenceController ()

@end

@implementation WRYEssenceController


/*
 抽取框架思想： 1.易用性 2.扩展性
 
 1.把相同功能放在基类 不同功能 由子类具体决定
 
 1.导航条内容 由子类决定
 2.有多少子控制器 由子类决定
 */


-(void)viewDidLoad
{
    [super viewDidLoad];
    //1.设置导航条内容
    [self setNavcItem];
 
    //2. 添加所有的子控制器
    [self setUpAllChildVC];

}

#pragma mark - 添加所有的子控制器
-(void)setUpAllChildVC
{
    //全部
    WRYAllController *allVC=[[WRYAllController alloc]init];
    allVC.title=@"全部";
    [self addChildViewController:allVC];
    //视频
    WRYVideoController *videoVC=[[WRYVideoController alloc]init];
    videoVC.title=@"视频";
    [self addChildViewController:videoVC];
    //声音
    WRYVoiceController *voiceVC=[[WRYVoiceController alloc]init];
    voiceVC.title=@"声音";
    [self addChildViewController:voiceVC];
    //图片
    WRYPictureController *pictureVC=[[WRYPictureController alloc]init];
    pictureVC.title=@"图片";
    [self addChildViewController:pictureVC];
    //段子
    WRYTextViewController *textVC=[[WRYTextViewController alloc]init];
    textVC.title=@"段子";
    [self addChildViewController:textVC];
    
        
}

#pragma mark - 设置导航条内容
-(void)setNavcItem
{
    //    推荐标签按钮
    UIBarButtonItem *itemL=[UIBarButtonItem itemWithNormalImage:[UIImage imageNamed:@"MainTagSubIcon"] highlightImage:[UIImage imageNamed:@"MainTagSubIconClick"] target:self action:@selector(itemLClick)];
    self.navigationItem.leftBarButtonItem=itemL;
    self.navigationItem.titleView=[[UIImageView alloc]initWithImage:[UIImage imageWitnOriginImageNamed:@"MainTitle"]];
}

#pragma mark - 点击推荐标签按钮
-(void)itemLClick
{
    WRYSubTagController * subTagVC=[[WRYSubTagController alloc]init];
    
    [self.navigationController pushViewController:subTagVC animated:YES];
    
}

@end
